From ec1133d6e17ca5d978c12efc2298c0530a8ac843 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sun, 21 Jun 2020 08:44:12 +0200 Subject: [PATCH] renderbackground: Only query number of layers once We did it once in snapshot_background and then again in snapshot_color. --- gtk/gtkrenderbackground.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c index 11c9c109c6..7630ab704b 100644 --- a/gtk/gtkrenderbackground.c +++ b/gtk/gtkrenderbackground.c @@ -47,14 +47,12 @@ static void gtk_theming_background_snapshot_color (GtkCssBoxes *boxes, GtkSnapshot *snapshot, const GdkRGBA *bg_color, - const GtkCssValue *background_image) + guint n_bg_values) { const GskRoundedRect *box; - gint n_values; GtkCssArea clip; - - n_values = _gtk_css_array_value_get_n_values (background_image); - clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_values - 1)); + + clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_bg_values - 1)); box = gtk_css_boxes_get_box (boxes, clip); if (gsk_rounded_rect_is_rectilinear (box)) @@ -264,7 +262,8 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes, gboolean has_bg_color; gboolean has_bg_image; gboolean has_shadow; - gint idx; + int idx; + guint number_of_layers; if (background->base.type == GTK_CSS_BACKGROUND_INITIAL_VALUES) return; @@ -288,10 +287,11 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes, snapshot, gtk_css_boxes_get_border_box (boxes)); + number_of_layers = _gtk_css_array_value_get_n_values (background_image); + if (has_bg_image) { GtkCssValue *blend_modes = background->background_blend_mode; - const int number_of_layers = _gtk_css_array_value_get_n_values (background_image); GskBlendMode *blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers); for (idx = number_of_layers - 1; idx >= 0; idx--) @@ -303,7 +303,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes, } if (has_bg_color) - gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image); + gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, number_of_layers); for (idx = number_of_layers - 1; idx >= 0; idx--) { @@ -321,7 +321,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes, } else if (has_bg_color) { - gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image); + gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, number_of_layers); } if (has_shadow) -- 2.30.2